/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Base;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author Alina
 */
public class AdministradorDB {

        public boolean grabarAdministrador(String cedula) throws SQLException {
        DatabaseManager db = new DatabaseManager();
        Connection var = db.getConnection();
        Statement stmt = var.createStatement();
        boolean resultado = stmt.execute("INSERT INTO ADMINISTRADOR VALUES ('" + cedula + "')");
        var.commit();
        db.getConnection().close();
        return resultado;
    }

    public boolean grabarAdministradorFacultad(String cedula, String fac) throws SQLException {
        DatabaseManager db = new DatabaseManager();
        Connection var = db.getConnection();
        Statement stmt = var.createStatement();
        boolean resultado = stmt.execute("INSERT INTO ADMINISTRADOR_FACULTAD VALUES ('" + cedula + "',"+fac+")");
        var.commit();
        db.getConnection().close();
        return resultado;
    }
    
    public boolean buscarAdministrador(String cedula) throws SQLException {
        
        DatabaseManager db = new DatabaseManager();
        Connection var = db.getConnection();
        Statement stmt = var.createStatement();
   
        String consulta = "SELECT * FROM ADMINISTRADOR WHERE CEDULA_ADMINISTRADOR='"+ cedula +"' "; 
        ResultSet resultado = stmt.executeQuery(consulta);
            while (resultado.next())
            {
                db.getConnection().close();
                return true;
            }
            
            db.getConnection().close();
            return false;
    }
    
}
